<!-- 订单信息-->
<style>
    .order_massage li{
        overflow: hidden;
        font-size: 16px;
		margin-bottom: 10px;
        color: #000;
    }
    .order_massage li:last-child{
        border-bottom: none;
    }
    .order_massage_title{
        float: left;
        width: 50%;
    }
    .order_common_title{
        float: left;
        width: 100%;
    }
</style>
<!-- 内容 -->
<div class="detail_content_wrap">
	<div class="layui-row">
		<div class="layui-col-md8">
			<div class="main_content_wrap">
				<p class="add_title">订单信息</p>
				<div class="layui-card-body" id="orderView"></div>
			</div>
		</div>
		<div class="layui-col-md4 detail_all_box">
			<!-- 详情 -->
			<div class="bg_white margin_top_20 gas_massage_wrap">
				<div class="layui-card-body" id="stationView"></div>
			</div>
		</div>
	</div>
</div>
<!--订单信息-->
<script id="orderDetail" type="text/html">
	<ul class='order_massage'>
		<li>
			<span class="order_massage_title">下单时间：{{d.add_datetime}}</span>
			<span class="order_massage_title">司机优惠券：{{d.driver_pay?d.total_price-d.driver_pay:0}}元</span>
		</li>
		<li>
			<span class="order_massage_title">物流公司：{{d.company_name?d.company_name:''}}</span>
			<span class="order_massage_title">司机实付金额：{{d.driver_pay?d.driver_pay:d.total_price}}元</span>
		</li>
		<li>
			<span class="order_massage_title">油站名称：{{d.station_name}}</span>
			<span class="order_massage_title">油站零售单价：{{d.station_price?d.station_price+'元':''}}</span>
		</li>
		<li>
			<span class="order_massage_title">油站单号：{{d.order_no?d.order_no:''}}</span>
			<span class="order_massage_title">油站订单金额：{{d.station_amount?d.station_amount+'元':''}}</span>
		</li>
		<li>
			<span class="order_massage_title">客户单号：{{d.customer_orderid?d.customer_orderid:''}}</span>
			<span class="order_massage_title">油站结算单价：{{d.settlement_price?d.settlement_price+'元':''}}</span>
		</li>
		<li>
			<span class="order_massage_title">卓壹单号：{{d.middle_order_no?d.middle_order_no:d.order_no}}</span>
			<span class="order_massage_title">实付油站金额：{{d.settle_amount?d.settle_amount+'元':''}}</span>
		</li>
		<li>
			<span class="order_massage_title">车牌号码：{{d.vehicle_license_num?d.vehicle_license_num:''}}</span>
			<span class="order_massage_title">油站来源渠道：{{d.station_source_name}}</span>
		</li>
		<li>
			<span class="order_massage_title">司机姓名：{{d.driver_name?d.driver_name:''}}</span>
			{{# if(d.station_source == 'zhuo'){ }}
			<span class="order_massage_title">油站订单状态：{{d.state_name}}</span>
			{{# }else{ }}
			<span class="order_massage_title">三方油站状态：{{d.station_state}}</span>
			{{# } }}
		</li>
		<li>
			<span class="order_massage_title">司机电话：{{d.driver_phone?d.driver_phone:''}}</span>
			<span class="order_massage_title">操作人员：{{d.opt_user_name?d.opt_user_name:''}}</span>
		</li>
		<li>
			<span class="order_massage_title">油品名称：{{d.oils_name}}</span>
			{{# if(d.state == 0){ }}
			<span class="order_massage_title">订单核销时间：{{d.work_off_datetime?d.work_off_datetime:''}}</span>
			{{# }else if(d.state == 1){ }}
			<span class="order_massage_title">订单取消时间：{{d.cancel_datetime?d.cancel_datetime:''}}</span>
			{{# } }}
		</li>
		<li>
			<span class="order_massage_title">油品单价：{{d.price}}元</span>
		</li>
		<li>
			<span class="order_massage_title">加油升数：{{d.count}}升</span>
		</li>
		<li>
			<span class="order_massage_title">加油金额：{{d.total_price}}元</span>
		</li>
		<li>
			<span class="order_massage_title">订单状态：{{d.state_name}}</span>
		</li>
		<li>
			<span class="order_common_title">备注信息：{{d.common?d.common:''}}</span>
		</li>
	</ul>
</script>
<!--油站信息-->
<script id="stationDetail" type="text/html">
	<p class='gas_massage_picture'><img id="picture" src='{{d.picture?d.picture:"assets/images/NoPath.png"}}' width="100%"></p>
	<ul class='gas_massage'>
		<li>
			<span class="gas_massage_title">油站名称</span>
			<span class="gas_massage_content">{{d.station_name}}</span>
		</li>
		<li>
			<span class="gas_massage_title">油站地址</span>
			<span class="gas_massage_content">{{d.address}}</span>
		</li>
		<li>
			<span class="gas_massage_title">油站来源</span>
			<span class="gas_massage_content">{{d.station_source_name}}</span>
		</li>
		<li>
			<span class="gas_massage_title">油站状态</span>
			<span class="gas_massage_content">{{d.station_status== 0 ? "已停用" : "正常服务"}}</span>
		</li>
		<li>
			<span class="gas_massage_title">油站品牌</span>
			<span class="gas_massage_content">{{d.brand_flow}}</span>
		</li>
		<li>
			<span class="gas_massage_title">经纬度</span>
			<span class="gas_massage_content" id="lng_lat">{{d.lng}},{{d.lat}}</span>
		</li>
		<li>
			<span class="gas_massage_title">联系电话</span>
			<span class="gas_massage_content">{{d.station_phone?d.station_phone:(d.concat_userphone?d.concat_userphone:'')}}</span>
		</li>
	</ul>
</script>
<script>

    layui.use(['jquery','form','config','laytpl'], function() {
        var $ = layui.jquery;
        var form = layui.form;
        var config = layui.config;
        var laytpl = layui.laytpl;

        var router = layui.router();
        var id = router.search.id;
        var userInfo = config.getUser();
        if(userInfo.company_id == 3){
            $('#sq').hide();
        }
        var data = {};
        var station = {};
        // 加载表单数据
        layer.load(2);
        $.post(serverUrl + 'Order/orderDetail', {'id': id}, function (res) {
            layer.closeAll('loading');
            if (res.success) {
                data = res.obj;
                station = res.obj.station;
                var state = '正常';
                if(res.obj.state == 1){
                    state = '已取消';
                }else if(res.obj.state == 2){
                    state = '待付款';
                }else if(res.obj.state == 3){
                    state = '待核销';
                }else if(res.obj.state == 4){
                    state = '退款中';
                }
                var station_state = '';
                if(res.obj.station_state == 1){
                    station_state = '已取消';
                }else if(res.obj.station_state == 2){
                    station_state = '待付款';
                }else if(res.obj.station_state == 3){
                    station_state = '待核销';
                }else if(res.obj.station_state == 4){
                    station_state = '退款中';
                }else if(res.obj.station_state == 0){
                    station_state = '已完成';
                }
                var station_source = '自有';
                if(station.station_flow === 'yoke'){
                    station_source = '智慧油客';
                }else if(station.station_flow === 'jiuhe'){
                    station_source = '九和';
                }else if(station.station_flow === 'laiyou'){
                    station_source = '来油';
                }
                data.station_name = station.station_name;
                data.station_source = station.station_flow;
                data.station_source_name = station_source;
                station.station_source_name = station_source;
                data.state_name = state;
                data.station_state = station_state;
                // 渲染订单信息详情
                var orderDetail = document.getElementById('orderDetail');
                var getOrderTpl = orderDetail.innerHTML;
                var orderView = document.getElementById('orderView');
                laytpl(getOrderTpl).render(data, function(html){
                    orderView.innerHTML = html;
                });

                // 渲染油站信息详情
                var stationDetail = document.getElementById('stationDetail');
                var getStationdTpl = stationDetail.innerHTML;
                var stationView = document.getElementById('stationView');
                laytpl(getStationdTpl).render(station, function(html){
                    stationView.innerHTML = html;
                });
            }
            return false;
        }, 'json');
    });

</script>